package com.mashang.utils;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class JdbcUtil {
    public static Connection getConnection() {


        Connection connection = null;
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");

            connection = DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306/javatest?userSSL=false&serverTimezone=Asia/Shanghai", "root", "123456");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return connection;
    }






    public static void close(Connection connection, Statement statement, ResultSet rs) {

        try {
            if (rs != null) {
                rs.close();
            }
            if (statement != null) {
                statement.close();
            }
            if (connection != null) {
                connection.close();
            }

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
